package edu.uoc.tdp.pac4.client;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;


import edu.uoc.tdp.pac4.client.Academic.Group_ViewGroup;
import edu.uoc.tdp.pac4.client.Academic.Registration_ViewRegistration;
import edu.uoc.tdp.pac4.client.logandreg.Attendance_StartAttendance;
import edu.uoc.tdp.pac4.client.logandreg.ChangeLanguageWindow;
import edu.uoc.tdp.pac4.client.logandreg.Attendance_CheckOutAttendances;
import edu.uoc.tdp.pac4.client.logandreg.Registration_ViewRegStatus;
import edu.uoc.tdp.pac4.client.maintenance.ClassroomSearchWindow;
import edu.uoc.tdp.pac4.client.maintenance.CourseSearchWindow;
import edu.uoc.tdp.pac4.client.maintenance.UserListWindow;
import edu.uoc.tdp.pac4.client.stats.StatsGeneralStaff;
import edu.uoc.tdp.pac4.client.stats.StatsGeneralTeacher;
import edu.uoc.tdp.pac4.client.stats.StatsStudent;

/**
 * 
 * @author Josep IA
 * Classe que gestiona els clicks del men� i mostra els panells necessaris segons la funci�.
 *
 */
public class ClientMenuActionListener implements ActionListener {
	
	private JFrame mainFrame;
	ClientConnectionHelper connectionHelper_ = null;
	
	public ClientMenuActionListener(JFrame contentFrame, ClientConnectionHelper connectionHelper) {
		this.mainFrame = contentFrame;
		connectionHelper_ = connectionHelper;
	}
	
	public void actionPerformed(ActionEvent e) {
		mainFrame.getContentPane().removeAll();
		//Statistics:
		  if(e.getActionCommand()=="main.menu.statistics.student"){
			  mainFrame.getContentPane().add(new StatsStudent(connectionHelper_));
		  }else if(e.getActionCommand()=="main.menu.statistics.teacher"){
			  mainFrame.getContentPane().add(new StatsGeneralTeacher(connectionHelper_));
		  }else if(e.getActionCommand()=="main.menu.statistics.staff"){
			  mainFrame.getContentPane().add(new StatsGeneralStaff(connectionHelper_));
		//Academic management:
		  } else if(e.getActionCommand()=="main.menu.groups"){
			  mainFrame.getContentPane().add(new Group_ViewGroup(connectionHelper_));
		  } else if(e.getActionCommand()=="main.menu.registrations"){
			  mainFrame.getContentPane().add(new Registration_ViewRegistration(connectionHelper_));
		  } else if(e.getActionCommand()=="main.menu.attendance"){
			  mainFrame.getContentPane().add(new Attendance_StartAttendance(connectionHelper_));
		//Connection and Registration
		  } else if(e.getActionCommand()=="main.menu.check.registration"){
			  mainFrame.getContentPane().add(new Registration_ViewRegStatus(connectionHelper_));	 
		  } else if(e.getActionCommand()=="main.menu.subscription.language"){
			  mainFrame.getContentPane().add(new ChangeLanguageWindow(mainFrame));	 
		  } else if(e.getActionCommand()=="main.menu.schedule.attendance"){
			  mainFrame.getContentPane().add(new Attendance_CheckOutAttendances(connectionHelper_));	 

		  } else if(e.getActionCommand()=="main.menu.user.list"){
			  //maintenance 
			  // user
			  mainFrame.getContentPane().add(new UserListWindow(connectionHelper_));	 
		  } else if(e.getActionCommand()=="main.menu.classroom.list"){
			  // classroom
			  mainFrame.getContentPane().add(new ClassroomSearchWindow(connectionHelper_));	 
		  } else if(e.getActionCommand()=="main.menu.course.list"){
			  //course
			  mainFrame.getContentPane().add(new CourseSearchWindow(connectionHelper_));	 

		  } else if(e.getActionCommand()=="Other_Action"){
			  //TODO
		  }else if(e.getActionCommand()=="Other_Action_2"){
			  //TODO
		  }

		  rePaint();
	  }
	
	public void rePaint() {
		mainFrame.pack();	
		mainFrame.setVisible(true);	

	}

}
